'''
Created on Apr 8, 2012
TestCase ID: Ecom_5003
Description: Kiem thu chuc nang xoa mot bai hoc
@author: Vu Dao
'''
import unittest
import HTMLTestRunner
import time
from Functions.globalFunc import readData, preCondition, endCondition
from Functions.loginPageFunc import login
from Functions.administratorFunc import clickOnBtnLessons
from Functions.lessonsFunc import deleteLesson, verifyLessonDeleted

username = readData("username")
password = readData("password")
lessonName = readData("lessonName",index=2)
class Ecom_5003(unittest.TestCase):


    def setUp(self):
        print "Buoc 1: Mo website"
        preCondition(self)

    def test_Ecom_5003(self):
        print "Buoc 2: Dang nhap vao website"
        login(self,username,password)
        
        print "Buoc 3: Click vao lessons button"
        clickOnBtnLessons(self)
        
        print "Buoc 4: Xoa mot bai hoc"
        deleteLesson(self,lessonName)
        
        print "Buoc 5 Kiem tra bai hoc da duoc xoa thanh cong"
#        time.sleep(3)
        self.assertFalse(verifyLessonDeleted(self,lessonName), "Failed: Bai hoc khong duoc xoa thanh cong")
        print "Passed: Bai hoc da duoc xoa thanh cong"

    def tearDown(self):
        print "Buoc 6: Dong website"
        endCondition(self)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5003)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang xoa mot bai hoc'
                    )
    runner.run(suite)